<template>
	<view class="auto-page" style="background-color: #FFFFFF;" v-if="statusStatistics && merchantMainData">
		<view class="data-filter">
			<view class="f-row" style="height: 78rpx;border-bottom: 2rpx solid #e8e8e8;">
				<view class="year-picker" :data-time="'year'" @click="dateFilter($event)">
					<image src="../../static/icons/order-list/down-arrow.png" mode="aspectFill"
						:class="dateSelect == 'year' ? 'rotate arrow-pic' : 'arrow-pic'"></image>
					<view :style="(dateSelectArr[0] == '' && dateSelectArr[1] == '') ? 'color:#999999' : ''"
						class="f-1 center picker-text">
						{{ (dateSelectArr[0] !== '' && dateSelectArr[1] !== '') ? dateSelectArr[0] + '年' + dateSelectArr[1] + '月' : '请选择年月' }}
					</view>
					<view v-if="dateSelect == 'year'" class="timepick-view f-column"
						@click.stop="() => {dateSelect = ''}" @touchmove.stop>
						<view class="picker f-column">
							<view class="f-row" style="position: absolute;top: 0;left: 0;right: 0;padding: 0 30rpx;">
								<view
									style="font-size: 26rpx;font-weight: bold;line-height: 80rpx;min-width: 100rpx;text-align: center;height: 80rpx;color: #999999;">
									取消</view>
								<view class="f-1"></view>
								<view
									style="font-size: 26rpx;font-weight: bold;line-height: 80rpx;min-width: 100rpx;text-align: center;height: 80rpx;color: #333333;"
									@click.stop="clearDateSelect">清空</view>
							</view>
							<view class="f-row" style="height: calc(30vh - 80rpx);top: 80rpx;">
								<view class="f-1 f-column m-tb-15" style="overflow-y: scroll;overflow-x: unset;">
									<view class="picker-item" v-for="(item,index) in years" :key="index"
										:style="dateSelectArr[0] == item ? 'color:#0388ff': ''"
										@click.stop="dateSelectFun(0,item)">
										{{item + '年'}}
									</view>
								</view>
								<view class="f-1 f-column m-tb-15" style="overflow-y: scroll;overflow-x: unset;">
									<view class="picker-item" v-for="(item,index) in months" :key="index"
										:style="dateSelectArr[1] == item ? 'color:#0388ff': ''"
										@click.stop="dateSelectFun(1,item)">
										{{item + '月'}}
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="f-1 f-row" style="justify-content: flex-end;">
					<view class="f-row click" style="height: 78rpx;line-height: 78rpx;margin-right: 15rpx;"
						@click="qrcodeverificate">
						<image src="../../static/icons/qrcodescan-blue.png" mode="aspectFill"
							style="height: 44rpx;width: 44rpx;margin: 17rpx 10rpx;"></image>
						<view style="font-size: 30rpx;">扫一扫订单核销</view>
					</view>
				</view>
			</view>
			<view class="f-row" style="height: 68rpx;line-height: 68rpx;border-bottom: 2rpx solid #e8e8e8;">
				<view class="header-title">订单统计</view>
				<view class="header-title-des center">本月累计交易订单（笔）</view>
				<view class="center" style="min-width: 70rpx;color: #1a66ff;padding-right: 30rpx;">
					{{merchantMainData.this_month_order}}
				</view>
			</view>
			<view class="orderstatus-list f-row">
				<view class="orderstatus-item" @click="osiClick(0)">
					<view class="orderstatus-item-title">全部</view>
				</view>
				<view class="orderstatus-item" @click="osiClick(1)">
					<view class="orderstatus-item-title">待付款</view>
					<view class="unread-dot" v-if="statusStatistics && statusStatistics.unpaid !== 0">
						<view style="color: #FFF;font-size: 20rpx;">
							{{statusStatistics.unpaid > 99 ? '...' : statusStatistics.unpaid}}
						</view>
					</view>
				</view>
				<view class="orderstatus-item" @click="osiClick(2)">
					<view class="orderstatus-item-title">待发货</view>
					<view class="unread-dot" v-if="statusStatistics && statusStatistics.unshipped !== 0">
						<view style="color: #FFF;font-size: 20rpx;">
							{{statusStatistics.unshipped > 99 ? '...' : statusStatistics.unshipped}}
						</view>
					</view>
				</view>
				<view class="orderstatus-item" @click="osiClick(3)">
					<view class="orderstatus-item-title">待评价</view>
					<view class="unread-dot" v-if="statusStatistics && statusStatistics.unevaluate !== 0">
						<view style="color: #FFF;font-size: 20rpx;">
							{{statusStatistics.unevaluate > 99 ? '...' : statusStatistics.unevaluate}}
						</view>
					</view>
				</view>
				<view class="orderstatus-item" @click="osiClickExt(4)">
					<view class="orderstatus-item-title">待退款</view>
					<view class="unread-dot" v-if="statusStatistics && statusStatistics.refund !== 0">
						<view style="color: #FFF;font-size: 20rpx;">
							{{statusStatistics.refund > 99 ? '...' : statusStatistics.refund}}
						</view>
					</view>
				</view>

				<view class="select-line transition-point-three" :style="orderStatusIndex == 0 ? 'transform: translateX(10vw)' :
												  orderStatusIndex == 1 ? 'transform: translateX(30vw)' :
												  orderStatusIndex == 2 ? 'transform: translateX(50vw)' :
												  orderStatusIndex == 3 ? 'transform: translateX(70vw)' : 
												  orderStatusIndex == 4 ? 'transform: translateX(90vw)' : 'transform: translateX(12.5vw)'"></view>
			</view>
		</view>
		<view class="f-column"
			style="position: relative;top: 230rpx;background-color: #FFFFFF;height: calc(100vh - 230rpx);">
			<scroll-view scroll-y="true" style="height: calc(100vh - 230rpx);" refresher-enabled="true"
				@refresherrefresh="refresherrefresh" :refresher-triggered="refreshing" @scrolltolower="scrolltolower"
				refresher-default-style="white" scroll-anchoring="true" refresher-threshold="250">
				<block v-if="orderStatusIndex !== 4 && data.length > 0">
					<view class="data-item f-column bg-white" v-for="(item, index) in data" :key="index">
						<view class="order-number single-text p-lr-30 nav-icon click">
							订单编号：{{item.order_sn}}
						</view>
						<view class="f-column p-lr-30">
							<view class="order-address single-text">
								下单时间：{{item.create_time}}
							</view>
							<view class="order-buyer single-text">
								收货人：{{item.real_name}} - {{item.user_phone}}
							</view>
							<view class="order-address single-text">
								收货地址：{{item.user_address}}
							</view>
							<view class="order-goods f-row" v-for="(goods , gindex) in item.orderProduct" :key="gindex">
								<view class="goods-pic-container">
									<image :src="goods.cart_info.product.image" mode="aspectFill"></image>
								</view>
								<view class="goods-detail f-1 f-column">
									<view class="goods-name double-text">{{goods.cart_info.product.store_name}}
									</view>
									<view class="goods-attr">{{goods.cart_info.productAttr.sku}}</view>
								</view>
								<view class="goods-number-price">
									<view class="goods-number"><span class="symbol">x</span>{{goods.product_num}}
									</view>
									<view class="goods-price single-text"><span
											class="symbol">￥</span>{{goods.product_price}}
									</view>
								</view>
							</view>
							<view class="f-row m-tb-15">
								<!-- order-time-status 下方元素原样式 -->
								<view class="f-1 f-column f-center">
									<view class="time gray-font line-40-24">订单状态</view>
									<!-- 0:待发货		1:待收货		2:待评价		3:已完成		-1:已退款 -->
									<view class="status line-40"
										:style="(item.status == 0 || item.status == 1 || item.status == 2) ? '' : 'color:#333333'">
										{{item.status == 0 && item.paid == 1 ? '待发货' :
																item.status == 0 && item.paid == 0 ? '待付款' :
																				 item.status == 1 ? '待收货' :
																				 item.status == 2 ? '待评价' :
																				 item.status == 3 ? '已退款' : 
																				 item.status == -1 ? '已拒绝退款' : '未知状态'}}
									</view>
								</view>
								<view class="f-1 f-column f-center">
									<view class="gray-font line-40-24">实付价</view>
									<view class="total-price line-40">{{item.pay_price}}</view>
								</view>
								<view class="f-1 f-column f-center">
									<view class="gray-font line-40-24">实付金额</view>
									<view class="real-price line-40">{{item.pay_price}}</view>
								</view>
							</view>
						</view>
						<view class="order-operation f-row">
							<view class="order-operation-button contect-buyer click-opacity" @click="callClick"
								:data-number="item.user_phone">
								<image class="order-operation-button-icon" mode="aspectFill"
									src="../../static/icons/order-list/phone.png"></image>
								<view class="order-operation-button-text" style="color: #333333;">联系买家</view>
							</view>
							<view class="order-operation-button send-goods click-opacity" v-if="item.status == 0 && item.paid == 1"
								@click="openSendGoods(item.order_id)">
								<image class="order-operation-button-icon" mode="aspectFill"
									src="../../static/icons/order-list/sendgoods.png"></image>
								<view class="order-operation-button-text">发货</view>
							</view>
						</view>
					</view>
				</block>
				<block class="f-column" v-if="orderStatusIndex == 4 & data.length > 0">
					<view class="data-item f-column bg-white" v-for="(item, index) in data" :key="index">
						<view class="order-number single-text p-lr-30 nav-icon click">
							订单编号：{{item.refund_order_sn}}
						</view>
						<view class="f-column p-lr-30">
							<view class="order-address single-text">
								下单时间：{{item.create_time}}
							</view>
							<view class="order-buyer single-text">
								收货人：{{item.user.nickname}} - {{item.user.phone}}
							</view>
							<view class="order-address single-text">
								退款原因：{{item.refund_message}}
							</view>
							<view class="order-address single-text">
								退款时间：{{item.create_time}}
							</view>
							<view class="order-goods f-row" v-for="(goods , gindex) in item.refundProduct"
								:key="gindex">
								<view class="goods-pic-container">
									<image :src="goods.product.cart_info.product.image" mode="aspectFill"></image>
								</view>
								<view class="goods-detail f-1 f-column">
									<view class="goods-name double-text">
										{{goods.product.cart_info.product.store_name}}
									</view>
									<view class="goods-attr">{{goods.product.cart_info.product.sku}}</view>
								</view>
								<view class="goods-number-price">
									<view class="goods-number"><span class="symbol">x</span>{{goods.refund_num}}
									</view>
									<view class="goods-price single-text"><span
											class="symbol">￥</span>{{goods.product.product_price}}
									</view>
								</view>
							</view>
							<view class="f-row m-tb-15">
								<!-- 						<view class="f-1 f-column center">
															<view class="gray-font line-50">总价</view>
															<view class="price line-50">{{item.total_price}}</view>
														</view> -->
								<view class="f-1 f-column center">
									<view class="gray-font line-40-24">订单状态</view>
									<!-- 0:待发货		1:待收货		2:待评价		3:已完成		-1:已退款 -->
									<view class="status line-40" :style="item.status == 0 ? '' : 'color:#333333'">
										{{item.status == 0 ? '待审核' :
																						 item.status == 3 ? '已退款' : 
																						 item.status == -1 ? '已拒绝退款' :'未知状态'}}
									</view>
								</view>
								<!-- 							<view class="f-1 f-column f-center">
													<view class="gray-font line-40-24">总价</view>
													<view class="total-price line-40">{{item.total_price}}</view>
												</view>
												<view class="f-1 f-column f-center">
													<view class="gray-font line-40-24">实付金额</view>
													<view class="real-price line-40">{{item.pay_price}}</view>
												</view> -->
								<view class="f-1 f-column f-center">
									<view class="gray-font line-40-24">实付价</view>
									<view class="total-price line-40">{{item.refund_price}}</view>
								</view>
								<view class="f-1 f-column center">
									<view class="gray-font line-40-24">退款金额</view>
									<view class="real-price line-40">{{item.refund_price}}</view>
								</view>
							</view>
						</view>
						<view class="order-operation f-row">
							<view class="order-operation-button click-opacity"
								style="background-color: #FFFFFF;min-width: 100rpx;box-sizing: border-box;border: 2rpx solid #e8e8e8;"
								@click="orderReFund(item.refund_order_id,-1)" v-if="item.status == 0">
								<view class="order-operation-button-text" style="color: #333333;">拒绝退款</view>
							</view>
							<view class="order-operation-button click-opacity"
								style="background-color: #DF2000;min-width: 100rpx;"
								@click="orderReFund(item.refund_order_id,1)" v-if="item.status == 0">
								<view class="order-operation-button-text" style="background-color: #007AFF;">退款
								</view>
							</view>
							<!-- 					<view class="order-operation-button send-goods click-opacity" v-if="item.status == 0"
														@click="openSendGoods(item.order_id)">
														<image class="order-operation-button-icon" mode="aspectFill"
															src="../../static/icons/order-list/sendgoods.png"></image>
														<view class="order-operation-button-text">发货</view>
													</view> -->
						</view>
					</view>
				</block>
				<block v-if="statusObject.status == 2 ||
					statusObject.status == 3 || statusObject.status == 4">
					<loading-more :statusObject="statusObject" @reload="reload"></loading-more>
				</block>
				<view class="f-column" style="height: calc(100vh - 230rpx);" v-else>
					<loading-more :statusObject="statusObject" @reload="reload"></loading-more>
				</view>
			</scroll-view>
		</view>
		<view class="sendgoods-popup f-column" v-if="sendgoods" @click="cancelsendgoods" @touchmove.stop.prevent>
			<view class="sendgoods-popup-body f-column bg-white p-lr-30 p-tb-15" @click.stop>
				<view class="sendgoods-header f-row">
					<view class="sendgoods-header-title">添加发货信息</view>
					<view style="position: absolute;top: 0;right: 0;" @click="cancelsendgoods">
						<view class="sendgoods-cancel-icon"></view>
					</view>
				</view>
				<view class="sendgoods-type p-lr-30">
					<view class="sendgoods-header-title">发货类型</view>
					<radio-group @change="sendGoodsTypeChange($event)">
						<label class="sendgoods-label">
							<radio :value="1" :checked="sendgoodstype == 1" /><text>发货</text>
						</label>
						<label class="sendgoods-label">
							<radio :value="2" :checked="sendgoodstype == 2" /><text>送货</text>
						</label>
						<label class="sendgoods-label">
							<radio :value="3" :checked="sendgoodstype == 3" /><text>无需物流</text>
						</label>
					</radio-group>
				</view>
				<view class="sendgoods-type-one f-column p-lr-30" v-if="sendgoodstype == 1">
					<view class="f-row">
						<view class="sendgoods-header-title">快递名称</view>
						<view class="f-column" style="margin-left: 30rpx;">
							<view @click="selectDelivery"
								:class="selecting ? 'delivery-choose-box nav-icon-rotate transition-point-three' : 'delivery-choose-box nav-icon transition-point-three'"
								:style="selecting ? 'height:' + ((storeOrderDelivery.length + 1)*56 + 4) + 'rpx;position:absolute' : 'height: 60rpx;position:absolute'">
								<view :style="deliveryValue ? '' : 'color:#999999'">{{deliveryValue.label || '请选择'}}
								</view>
								<view v-for="(item , index) in storeOrderDelivery" :key="index"
									@click.stop="chooseDelivery(item)">
									{{item.label}}
								</view>
							</view>
						</view>
					</view>
					<view class="f-row y-center">
						<view class="sendgoods-header-title">快递单号</view>
						<view class="sendgoods-header-content" style="display: flex;">
							<input style="display: inline-block;flex: 1;" type="text" placeholder="请输入快递单号..."
								@input="deliveryNumberInput">
						</view>
					</view>
				</view>
				<view class="sendgoods-type-one f-column p-lr-30" v-if="sendgoodstype == 2">
					<view class="f-row y-center">
						<view class="sendgoods-header-title">送货人名称</view>
						<view class="sendgoods-header-content" style="display: flex;">
							<input style="display: inline-block;flex: 1;" type="text" placeholder="请输入送货人名称..."
								@input="deliveryManInput">
						</view>
					</view>
					<view class="f-row y-center">
						<view class="sendgoods-header-title">手机号</view>
						<view class="sendgoods-header-content" style="display: flex;">
							<input style="display: inline-block;flex: 1;" type="number" placeholder="请输入手机号..."
								@input="deliveryManPhoneInput">
						</view>
					</view>
				</view>
				<view style="width: 100%;height: 90rpx;"></view>
				<view class="send-goods-button" @click="sendGoodsSubmit">发货</view>
			</view>
		</view>
	</view>
</template>

<script>
	let _this;
	const date = new Date()
	const years = []
	const year = date.getFullYear()
	const months = []
	const month = date.getMonth() + 1
	for (let i = year - 5; i <= year + 5; i++) {
		years.push(i)
	}
	for (let i = 1; i <= 12; i++) {
		months.push(i)
	}
	import loadingMore from '../../components/loading-more.vue'
	import {
		dateStr,
		showToast
	} from '../../lib/utils.js'
	import ORDER from '../../api/order.js'
	export default {
		components: {
			loadingMore
		},
		data() {
			return {
				years,
				year,
				months,
				month,
				dateSelect: '',
				dateSelectArr: ['', ''],
				dateStr: '',
				statusStatistics: false,
				orderStatusIndex: 0,
				page: 1,
				limit: 5,
				order_type: -1,
				statusObject: {
					status: 0
				},
				data: [],
				sendgoods: false,
				sendgoodstype: 1,
				storeOrderDelivery: false,
				sendgoodsid: false,
				delivery_type: 1,
				delivery_name: '',
				delivery_id: '',
				selecting: false,
				deliveryNumber: '',
				deliveryValue: false,
				deliveryManName: '',
				deliveryManPhone: '',
				merchantMainData: false,
				refreshing: false,
			}
		},
		onLoad() {
			_this = this;
			if(_this.data.length === 0) {
				ORDER.orderChart().then((res) => {
					_this.statusStatistics = res;
					console.log(res);
				}).catch((err) => {
					_this.statusObject = {
						status: -1
					};
				});
				if (_this.orderStatusIndex == 4) {
					ORDER.refundOrderLst({
						page: _this.page,
						limit: _this.limit,
					}).then((res) => {
						console.log(res);
						_this.data = _this.data.concat(res.list);
						if (res.count == 0) {
							_this.statusObject = {
								status: 1
							};
						} else if ((_this.data.length == res.count && res.count !== 0) || res.data
							.data.list.length == 0) {
							_this.statusObject = {
								status: 2
							};
							_this.page += 1;
						} else {
							_this.statusObject = {
								status: 3
							};
							_this.page += 1;
						}
					}).catch((err) => {
						_this.statusObject = {
							status: -1
						};
						console.log(err);
					});
				} else {
					_this.requestData();
				}
				_this.merchantMainData = getApp().globalData.merchantMainData;
			}
		},
		onShow() {
			let STORAGE_DATA = uni.getStorageSync('STORAGE_DATA');
			_this.data = [];
			_this.page = 1;
			_this.statusObject = { status: 0 }
			ORDER.orderChart().then((res) => {
				_this.statusStatistics = res;
				console.log(res);
			}).catch((err) => {
				_this.statusObject = {
					status: -1
				};
			});
			if (STORAGE_DATA) {
				_this.orderStatusIndex = STORAGE_DATA;
				uni.removeStorageSync('STORAGE_DATA');
			}
			if (_this.orderStatusIndex == 4) {
				ORDER.refundOrderLst({
					page: _this.page,
					limit: _this.limit,
				}).then((res) => {
					console.log(res);
					_this.data = _this.data.concat(res.list);
					if (res.count == 0) {
						_this.statusObject = {
							status: 1
						};
					} else if ((_this.data.length == res.count && res.count !== 0) || res.data
						.data.list.length == 0) {
						_this.statusObject = {
							status: 2
						};
						_this.page += 1;
					} else {
						_this.statusObject = {
							status: 3
						};
						_this.page += 1;
					}
				}).catch((err) => {
					_this.statusObject = {
						status: -1
					};
					console.log(err);
				});
			} else {
				console.log(1)
				_this.requestData();
			}
			_this.merchantMainData = getApp().globalData.merchantMainData;
		},
		onReachBottom() {
			if (_this.statusObject.status !== 3) return;
			if (_this.orderStatusIndex !== 4) {
				_this.requestData();
			} else {
				ORDER.refundOrderLst({
					page: _this.page,
					limit: _this.limit,
				}).then((res) => {
					console.log(res);
					_this.data = _this.data.concat(res.list);
					if (res.count == 0) {
						_this.statusObject = {
							status: 1
						};
					} else if ((_this.data.length == res.count && res.count !== 0) || res.list.length == 0) {
						_this.statusObject = {
							status: 2
						};
						_this.page += 1;
					} else {
						_this.statusObject = {
							status: 3
						};
						_this.page += 1;
					}
				}).catch((err) => {
					_this.statusObject = {
						status: -1
					};
				});
			}
		},
		methods: {
			scrolltolower() {
				if (_this.statusObject.status !== 3) return;
				if (_this.orderStatusIndex !== 4) {
					_this.requestData();
				} else {
					ORDER.refundOrderLst({
							page: _this.page,
							limit: _this.limit,
					}).then((res) => {
						console.log(res);
						_this.data = _this.data.concat(res.list);
						if (res.count == 0) {
							_this.statusObject = {
								status: 1
							};
						} else if ((_this.data.length == res.count && res.count !== 0) || res.list.length == 0) {
							_this.statusObject = {
								status: 2
							};
							_this.page += 1;
						} else {
							_this.statusObject = {
								status: 3
							};
							_this.page += 1;
						}
					}).catch((err) => {
						_this.statusObject = {
							status: -1
						};
					});
				}
			},
			refresherrefresh() {
				if (_this.refreshing) return;
				_this.refreshing = true;
				let result = [];
				_this.page = 1;
				if (_this.orderStatusIndex == 4) {
					ORDER.refundOrderLst({
						page: _this.page,
						limit: _this.limit,
						date: _this.dateStr
					}).then((res) => {
						result = result.concat(res.list);
						if (res.count == 0) {
							_this.statusObject = {
								status: 1
							};
						} else if ((res.data.length == res.count && res.count !== 0) || res.list.length == 0) {
							_this.statusObject = {
								status: 2
							};
							_this.page += 1;
						} else {
							_this.statusObject = {
								status: 3
							};
							_this.page += 1;
						}
						_this.data = result;
						_this.refreshing = false;
					}).catch((err) => {
						_this.statusObject = {
							status: -1
						};
						_this.refreshing = false;
					});
				} else {
					ORDER.orderLst({
						page: _this.page,
						limit: _this.limit,
						order_type: _this.order_type,
						status: _this.orderStatusIndex,
						date: _this.dateStr
					}).then((res) => {
						console.log(res);
						result = result.concat(res.list);
						if (res.count == 0) {
							_this.statusObject = {
								status: 1
							};
						} else if (result.length == res.count || res.list.length == 0) {
							_this.statusObject = {
								status: 2
							};
							_this.page += 1;
						} else {
							_this.statusObject = {
								status: 3
							};
							_this.page += 1;
						}
						_this.data = result;
						_this.refreshing = false;
					}).catch((err) => {
						_this.statusObject = {
							status: -1
						};
						_this.refreshing = false;
						console.log(err);
					});
				}
			},
			consoleOrder(item) {
				console.log(item);
			},
			clearDateSelect() {
				_this.dateSelectArr = ['', ''];
				_this.dateSelect = '';
				_this.dateStr = '';
				_this.data = [];
				_this.page = 1;
				_this.statusObject = {
					status: 0
				};
				switch (_this.orderStatusIndex) {
					case 4:
						ORDER.refundOrderLst({
							page: _this.page,
							limit: _this.limit,
							date: _this.dateStr
						}).then((res) => {
							_this.data = _this.data.concat(res.list);
							if (res.count == 0) {
								_this.statusObject = {
									status: 1
								};
							} else if ((_this.data.length == res.count && res.count !== 0) ||
								res.list.length == 0) {
								_this.statusObject = {
									status: 2
								};
								_this.page += 1;
							} else {
								_this.statusObject = {
									status: 3
								};
								_this.page += 1;
							}
						}).catch((err) => {
							_this.statusObject = {
								status: -1
							};
						});
						break;
					default:
						_this.requestData();
						break;
				}
			},
			reload() {
				_this.page = 1;
				_this.statusObject = {
					status: 0
				};
				_this.data = [];
				if (_this.orderStatusIndex == 4) {
					ORDER.refundOrderLst({
						page: _this.page,
						limit: _this.limit,
						date: _this.dateStr
					}).then((res) => {
						_this.data = _this.data.concat(res.list);
						if (res.count == 0) {
							_this.statusObject = {
								status: 1
							};
						} else if ((_this.data.length == res.count && res.count !== 0) || res
							.data.data.list.length == 0) {
							_this.statusObject = {
								status: 2
							};
							_this.page += 1;
						} else {
							_this.statusObject = {
								status: 3
							};
							_this.page += 1;
						}
					}).catch((err) => {
						_this.statusObject = {
							status: -1
						};
					});
				} else {
					_this.requestData();
				}
			},
			orderReFund(id, status) {
				let fail_message
				uni.showModal({
					title: '确认退款吗？',
					success: (res) => {
						if (res.confirm) {
							ORDER.refundOrderStatus({
								id: id,
								status: status,
								fail_message: status == -1 ? '拒绝退款' : ''
							}).then((res) => {
								console.log(res);
								showToast(res.data.message);
								_this.reload();
							}).catch((err) => {
								console.log(err);
								showToast('退款失败');
							});
						}
					}
				})

			},
			dateFilter(e) {
				console.log(e.currentTarget.dataset.time);
				if (_this.dateSelect == e.currentTarget.dataset.time) {
					_this.dateSelect = '';
					return;
				}
				_this.dateSelect = e.currentTarget.dataset.time;
			},
			dateSelectFun(index, item) {
				if (index == 1 && _this.dateSelectArr[0] == '') {
					uni.showToast({
						title: '请选择年份',
						icon: 'none'
					});
					return;
				}
				let arr = JSON.parse(JSON.stringify(_this.dateSelectArr));
				arr[index] = item;
				_this.dateSelectArr = arr;
				if (index == 1) {
					_this.dateSelect = ''
					_this.dateStr = dateStr(_this.dateSelectArr[0], _this.dateSelectArr[1]);
					_this.data = [];
					_this.page = 1;
					_this.statusObject = {
						status: 0
					};
					switch (_this.orderStatusIndex) {
						case 4:
							ORDER.refundOrderLst({
								page: _this.page,
								limit: _this.limit,
								date: _this.dateStr
							}).then((res) => {
								_this.data = _this.data.concat(res.list);
								if (res.count == 0) {
									_this.statusObject = {
										status: 1
									};
								} else if ((_this.data.length == res.count && res.count !==
										0) || res
									.data.data.list.length == 0) {
									_this.statusObject = {
										status: 2
									};
									_this.page += 1;
								} else {
									_this.statusObject = {
										status: 3
									};
									_this.page += 1;
								}
							}).catch((err) => {
								_this.statusObject = {
									status: -1
								};
							});
							break;
						default:
							_this.requestData();
							break;
					}
				}
			},
			qrcodeverificate() {
				uni.scanCode({
					onlyFromCamera: true,
					scanType: ['qrCode'],
					onlyFromCamera: false,
					success: (suc) => {
						uni.showModal({
							content: '确认核销此订单吗？',
							confirmText: '确定',
							cancelText: '取消',
							success: (choose) => {
								console.log(choose);
								if (choose.confirm) {
									ORDER.orderVerify({
										orderVerifyId: suc.result
									}).then((res) => {
										console.log(res);
									}).catch((err) => {
										showToast(err.data.message);
									});
								} else {
									showToast('已取消');
								}

							}
						});
					}
				});
			},
			osiClick(index) {
				_this.orderStatusIndex = index;
				_this.dateSelectArr = ['', ''];
				_this.dateStr = '',
					_this.page = 1;
				_this.statusObject = {
					status: 0
				};
				_this.data = [];
				_this.requestData();
			},
			requestData() {
				if (_this.statusObject.status == 1 || _this.statusObject.status == 2) return;
				ORDER.orderLst({
					page: _this.page,
					limit: _this.limit,
					order_type: _this.order_type,
					status: _this.orderStatusIndex,
					date: _this.dateStr
				}).then((res) => {
					console.log(res);
					_this.data = _this.data.concat(res.list);
					if (res.count == 0) {
						_this.statusObject = {
							status: 1
						};
					} else if (_this.data.length == res.count || res.list.length == 0) {
						_this.statusObject = {
							status: 2
						};
						_this.page += 1;
					} else {
						_this.statusObject = {
							status: 3
						};
						_this.page += 1;
					}
				}).catch((err) => {
					_this.statusObject = {
						status: -1
					};
					console.log(err);
				});
			},
			callClick(e) {
				uni.makePhoneCall({
					phoneNumber: e.currentTarget.dataset.number
				});
			},
			osiClickExt(index) {
				_this.orderStatusIndex = index;
				_this.dateSelectArr = ['', ''];
				_this.dateStr = '',
					_this.page = 1;
				_this.statusObject = {
					status: 0
				};
				_this.data = [];
				ORDER.refundOrderLst({
					page: _this.page,
					limit: _this.limit,
					date: _this.dateStr
				}).then((res) => {
					_this.data = _this.data.concat(res.list);
					if (res.count == 0) {
						_this.statusObject = {
							status: 1
						};
					} else if ((_this.data.length == res.count && res.count !== 0) || res.data
						.data.list.length == 0) {
						_this.statusObject = {
							status: 2
						};
						_this.page += 1;
					} else {
						_this.statusObject = {
							status: 3
						};
						_this.page += 1;
					}
				}).catch((err) => {
					_this.statusObject = {
						status: -1
					};
				});
			},
			openSendGoods(id) {
				_this.sendgoods = true;
				_this.sendgoodsid = id;
				if (!_this.storeOrderDelivery) {
					ORDER.orderDelivery({
						id: _this.sendgoodsid
					}).then((res) => {
						console.log(res);
						_this.storeOrderDelivery = res.rule[0].control[0].rule[0].options;
					}).catch((err) => {
						console.log(err);
					});
				}
			},
			sendGoodsTypeChange(e) {
				_this.sendgoodstype = e.target.value;
				console.log(_this.sendgoodstype);
			},
			cancelsendgoods() {
				_this.sendgoods = false;
			},
			selectDelivery() {
				_this.selecting = _this.selecting ? false : true;
			},
			chooseDelivery(item) {
				_this.deliveryValue = item;
				console.log(item);
				_this.selecting = false;
			},
			deliveryNumberInput(e) {
				_this.deliveryNumber = e.detail.value;
			},
			deliveryManInput(e) {
				_this.deliveryManName = e.detail.value;
			},
			deliveryManPhoneInput(e) {
				_this.deliveryManPhone = e.detail.value;
			},
			sendGoodsSubmit() {
				if (_this.sendgoodstype == 1) {
					if (!_this.deliveryValue) {
						showToast('未选择快递');
						return
					} else if (_this.deliveryNumber.trim() == '' || _this.deliveryNumber == '') {
						showToast('未填写快递单号');
						return
					}
					uni.showModal({
						title: '确认发货吗？',
						success: (res) => {
							if (res.confirm) {
								ORDER.orderDelivery({
									id: _this.sendgoodsid,
									delivery_type: _this.sendgoodstype,
									delivery_name: _this.deliveryValue.value,
									delivery_id: _this.deliveryNumber
								}).then((res) => {
									console.log(res);
									showToast(res.data.message);
									_this.sendgoods = false;
								}).catch((err) => {
									console.log(err);
									showToast(err.data.message);
								});
							}
						}
					});
				} else if (_this.sendgoodstype == 2) {
					if (_this.deliveryManName.trim() == '' || _this.deliveryManName == '') {
						showToast('送货人名称不能为空');
						return
					} else if (_this.deliveryManName.length < 2) {
						showToast('送货人名称长度过短');
						return
					} else if (_this.deliveryManPhone.length !== 11 || !(/^1(3|4|5|6|7|8|9)\d{9}$/.test(_this
							.deliveryManPhone))) {
						showToast('非法手机号码');
						return
					}
					uni.showModal({
						title: '确认发货吗？',
						success: (res) => {
							if (res.confirm) {
								ORDER.orderDelivery({
									id: _this.sendgoodsid,
									delivery_type: _this.sendgoodstype,
									delivery_name: _this.deliveryManName,
									delivery_id: _this.deliveryManPhone
								}).then((res) => {
									console.log(res);
									showToast(res.data.message);
									_this.sendgoods = false;
								}).catch((err) => {
									console.log(err);
									showToast(err.data.message);
								});
							}
						}
					});
				} else if (_this.sendgoodstype == 3) {
					uni.showModal({
						title: '确认发货吗？',
						success: (res) => {
							if (res.confirm) {
								ORDER.orderDelivery({
									id: _this.sendgoodsid,
									delivery_type: _this.sendgoodstype
								}).then((res) => {
									console.log(res);
									showToast(res.message);
									_this.sendgoods = false;
								}).catch((err) => {
									console.log(err);
									showToast(err.message);
								});
							}
						}
					});
				}
			},
		},
		computed: {

		}
	}
</script>

<style scoped>
	.data-filter {
		position: fixed;
		display: flex;
		flex-direction: column;
		top: 0;
		left: 0;
		right: 0;
		border-bottom: 2rpx solid #e8e8e8;
		background-color: #FFFFFF;
		z-index: 9999;
	}

	.year-picker {
		height: 78rpx;
		padding-left: 60rpx;
		position: relative;
		display: flex;
		flex-direction: row;
		line-height: 78rpx;
		width: 165rpx;
		margin-right: 30rpx;
	}

	.picker-text {
		font-size: 28rpx;
		min-width: 150rpx;
	}

	.arrow-pic {
		height: 30rpx;
		width: 30rpx;
		position: absolute;
		left: 30rpx;
		top: 50%;
		margin-top: -15rpx;
	}

	.rotate {
		animation: rotate .15s linear forwards;
	}

	@keyframes rotate {
		from {
			transform: rotate(0);
		}

		to {
			transform: rotate(180deg);
		}
	}

	.timepick-view {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		top: 0;
		background-color: rgba(33, 33, 33, .4);
		z-index: 10000;
	}

	.picker {
		position: absolute;
		left: 0;
		right: 0;
		height: 30vh;
		bottom: 0;
		background-color: #FFFFFF;
		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
		animation: pickerup .3s ease forwards;
		overflow: hidden;
	}

	@keyframes pickerup {
		from {
			transform: translateY(30vh);
		}

		to {
			transform: translateY(0vh);
		}
	}

	.picker-item {
		height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		font-size: 30rpx;
	}

	.header-title::before {
		content: "";
		width: 2rpx;
		border-left: 10rpx solid #1a66ff;
		height: 58rpx;
		margin: 5rpx 15rpx;
	}

	.header-title {
		font-size: 30rpx;
		font-weight: bold;
	}

	.header-title-des {
		font-size: 30rpx;
		margin-left: 15rpx;
		flex: 1;
	}

	.orderstatus-list {
		position: relative;
		height: 78rpx;
	}

	.orderstatus-item {
		height: 78rpx;
		flex: 1;
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.orderstatus-item-title {
		font-size: 24rpx;
		height: 78rpx;
		line-height: 78rpx;
	}

	.select-line {
		position: absolute;
		bottom: 0;
		height: 4rpx;
		width: 80rpx;
		background-color: #007AFF;
		margin-left: -40rpx;
	}

	.data-item {
		margin: 20rpx 30rpx 0 30rpx;
		border-radius: 20rpx;
		border: 2rpx solid #e8e8e8;
	}

	.order-number {
		height: 70rpx;
		line-height: 70rpx;
		font-size: 26rpx;
		font-weight: bold;
		border-bottom: 2rpx solid #d8d8d8;
	}

	.order-buyer,
	.order-address {
		height: 50rpx;
		line-height: 50rpx;
		font-size: 24rpx;
	}

	.order-goods {
		margin-top: 15rpx;
	}

	.goods-pic-container,
	.goods-pic-container image {
		height: 150rpx;
		width: 150rpx;
		border-radius: 10rpx;
	}

	.goods-detail {
		margin-left: 15rpx;
	}

	.goods-name {
		font-size: 24rpx;
		font-weight: bold;
	}

	.goods-number-price {
		width: max-content;
		max-width: 130rpx;
	}

	.goods-number,
	.goods-price {
		font-size: 28rpx;
		text-align: right;
	}

	.goods-price,
	.goods-price .symbol {
		color: #DF2000;
	}

	.goods-price .symbol {
		font-size: 24rpx;
	}

	.goods-attr {
		color: #999999;
		font-size: 22rpx;
	}

	.price {
		font-size: 28rpx;
	}

	.order-time-status {
		padding: 0 15rpx;
		min-width: 150rpx;
	}

	.time {
		font-size: 24rpx;
	}

	.status {
		font-size: 26rpx;
		font-weight: bold;
		color: #df2000;
	}

	.line-40-24 {
		line-height: 50rpx;
		font-size: 24rpx;
	}

	.order-operation {
		justify-content: flex-end;
		padding-bottom: 15rpx;
		padding: 0 15rpx 15rpx 15rpx;
		width: calc(100% - 30rpx);
	}

	.order-operation-button {
		display: flex;
		flex-direction: row;
		position: relative;
		height: 50rpx;
		align-items: center;
		justify-content: center;
		padding-right: 15rpx;
		padding-left: 15rpx;
		border-radius: 12rpx;
		margin: 0 15rpx;
	}

	.order-operation-button-text {
		font-size: 24rpx;
		color: #FFFFFF;
	}

	.order-operation-button-icon {
		height: 24rpx;
		width: 24rpx;
		margin-right: 10rpx;
		vertical-align: baseline;
	}

	.contect-buyer {
		border: 2rpx solid #e8e8e8;
	}

	.send-goods {
		background-color: #DF2000;
	}

	.contect-buyer .order-operation-button-text,
	.send-goods .order-operation-button-text {
		color: #FFFFFF;
	}

	.sendgoods-popup {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 100;
		background: rgba(33, 33, 33, .5);
		justify-content: center;
		align-items: center;
	}

	.sendgoods-popup-body {
		border-radius: 16rpx;
		height: auto;
		width: 80vw;
		animation: show .25s linear 1;
	}

	@keyframes show {
		from {
			transform: translateY(-50px);
			opacity: 0;
		}

		to {
			transform: translateY(0);
			opacity: 1;
		}
	}

	.sendgoods-cancel-icon {
		display: inline-block;
		width: 20px;
		height: 2px;
		background: #999;
		transform: rotate(45deg);
	}

	.sendgoods-cancel-icon::after {
		content: '';
		display: block;
		width: 20px;
		height: 2px;
		background: #999;
		transform: rotate(-90deg);
	}

	.sendgoods-header,
	.sendgoods-header-title {
		height: 70rpx;
		line-height: 70rpx;
		font-size: 28rpx;
	}

	.sendgoods-header-content {
		box-sizing: border-box;
		height: 60rpx;
		line-height: 56rpx;
		font-size: 24rpx;
		border: 2rpx solid #e8e8e8;
		border-radius: 10rpx;
		margin-left: 30rpx;
		flex: 1;
	}

	.sendgoods-header-content input {
		height: 56rpx;
		line-height: 56rpx;
		font-size: 24rpx;
		width: calc(100% - 20rpx);
		padding: 0 10rpx;
	}

	.sendgoods-label {
		line-height: 60rpx;
		font-size: 24rpx;
		margin-right: 30rpx;
	}

	.delivery-choose-box {
		box-sizing: border-box;
		border: 2rpx solid #d8d8d8;
		text-align: left;
		padding-left: 15rpx;
		position: absolute;
		top: 0;
		left: 0;
		border-radius: 10rpx;
		width: 200rpx;
		background-color: #FFFFFF;
		overflow: hidden;
		z-index: 999;
	}

	.delivery-choose-box view {
		font-size: 24rpx;
		line-height: 56rpx;
		height: 56rpx;
	}

	.sendgoods-type-one {
		margin: 30rpx 0;
	}

	.nav-icon::after {
		top: 30rpx;
	}

	.nav-icon-rotate {
		padding-right: 0;
		position: relative;
	}

	.nav-icon-rotate:after {
		content: " ";
		height: 15rpx;
		width: 15rpx;
		border-width: 1px 1px 0 0;
		border-color: #999999;
		border-style: solid;
		transform: rotate(45deg);
		position: absolute;
		margin-top: -10rpx;
		top: 30rpx;
		right: 30rpx;
		animation: scoperotate .1s linear 1;
		animation-fill-mode: forwards;
	}

	@keyframes scoperotate {
		from {
			transform: rotate(45deg);
		}

		to {
			transform: rotate(135deg);
		}
	}

	.send-goods-button {
		height: 60rpx;
		line-height: 60rpx;
		background-color: #DF2000;
		font-size: 26rpx;
		font-weight: bold;
		border-radius: 10rpx;
		color: #FFFFFF;
		text-align: center;
		position: absolute;
		bottom: 30rpx;
		left: 30rpx;
		right: 30rpx;
	}

	.send-goods-button:active {
		opacity: .7;
	}

	.unread-dot {
		height: 30rpx;
		width: 30rpx;
		border-radius: 15rpx;
		background-color: #1a66ff;
		position: absolute;
		right: 10rpx;
		top: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.line-40 {
		line-height: 40rpx;
	}
</style>
